/**
 * 验证 useState 的逻辑
 */

import React, { useState } from 'react'
import { flushSync } from 'react-dom'
import { Button } from 'antd'

function Demo() {
  let [x, setX] = useState(1)
  console.log('RENDER', x)
  let handleClick = () => {
    for (let i = 0; i < 10; i++) {
      flushSync(() => {
        setX(x + 1)
      })
    }
  }

  return <div>
    <div>{x}</div>
    <Button onClick={handleClick}>新增</Button>
  </div>
}

export default Demo